home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / vuser / main.c < prev    next >
C/C++ Source or Header  |  1995-06-20  |  3KB  |  105 lines

  1. /* main.c - This module contains the startup code for the vuser program.
  2.  
  3.     Copyright 1989 by Jeffrey F. Lawhorn  (jeffl@berick.uucp)
  4.  
  5.     This file is part of vuser.
  6.  
  7.     vuser is free software; you can redistribute it and/or modify it
  8.     under the terms of the GNU General Public License as published by
  9.     the Free Software Foundation; either version 1, or (at your
  10.     option) any later version.
  11.  
  12.     vuser is distributed in the hope that it will be useful, but
  13.     WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.     General Public License for more details.
  16.  
  17.     You should have received a copy of the GNU General Public License
  18.     along with GNU CC; see the file COPYING.  If not, write to the
  19.     Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  20. */
  21.  
  22. #if !defined(lint)
  23. static char SCCSid[] = "$Id: main.c,v 1.1 89/12/15 21:30:53 jeffl Exp $";
  24. #endif
  25.  
  26. #include <stdio.h>
  27. #include <signal.h>
  28.  
  29. #if defined(__STDC__)
  30. extern void Tty2ProgramMode();
  31. extern void GetPty();
  32. extern void StartSlave();
  33. extern void HaveFun();
  34. #else
  35. extern void Tty2ProgramMode();
  36. extern void GetPty();
  37. extern void StartSlave();
  38. extern void HaveFun();
  39. #endif
  40.  
  41. extern char *optarg;
  42. extern int optind;
  43.  
  44. extern int PromptSize;
  45. extern char **Program2Run;
  46. extern char *RloginProgram[];
  47.  
  48. #if defined(TIMEOUT_IS_LONG)
  49. extern long TimeOut;
  50. #else
  51. #include <sys/time.h>
  52. extern struct timeval TimeOut;
  53. #endif
  54.  
  55. FILE *ScriptFile = (FILE *)NULL;
  56. FILE *RecordFile = (FILE *)NULL;
  57.  
  58. main(argc, argv)
  59. int argc;
  60. char *argv[];
  61. {
  62.     loop: switch(getopt(argc, argv, "s:p:t:e:l:r:")) {
  63.     case EOF: break;
  64.     case 's': {
  65.         if(!(ScriptFile = fopen(optarg, "w"))) {
  66.         perror(optarg);
  67.         exit(1);
  68.         }
  69.         goto loop;
  70.     }
  71.     case 'p': {
  72.         if((PromptSize = atoi(optarg)) > 4096) {
  73.         fprintf(stderr, "Prompt size is limited to 4096.\n");
  74.         PromptSize = 4096;
  75.         }
  76.         goto loop;
  77.     }
  78. #if defined(TIMEOUT_IS_LONG)
  79.     case 't': TimeOut = atol(optarg); goto loop;
  80. #else
  81.     case 't': TimeOut.tv_sec = atol(optarg); goto loop;
  82. #endif
  83.     case 'e': Program2Run = &argv[optind - 1]; break;
  84.     case 'l': {
  85.         RloginProgram[2] = argv[optind];
  86.         RloginProgram[4] = argv[optind - 1];
  87.         break;
  88.     }
  89.     case 'r': {
  90.         if(!(RecordFile = fopen(optarg, "w"))) {
  91.         perror(optarg);
  92.         exit(1);
  93.         }
  94.         goto loop;
  95.     }
  96.     default: exit(1);
  97.     }
  98.     setbuf(stdin, (char *)NULL);
  99.     signal(SIGINT, SIG_IGN);
  100.     Tty2ProgramMode();
  101.     GetPty();
  102.     StartSlave();
  103.     HaveFun();
  104. }
  105.